/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Trabalho3.RegrasPasswordChecker02;

import Trabalho3.RuleFactory;

/**
 *
 * @author geraldo
 */
public class RegraDescontoSomenteLetras implements RuleFactory{
    String password;

    public RegraDescontoSomenteLetras(String password) {
        this.password = password;
    }
    
    
    @Override
    public int calcularRegra() {
        return isAlphasOnly()? password.length()*-1:0;
    
    }
    
     public boolean isAlphasOnly() {
        for (char ch : password.toCharArray()) {
            if (!Character.isLetter(ch)) {
                return false;
            }
        }
        return !password.isEmpty();
    }
    
}
